<template>
  <div class="list">
    <ul>
      <li v-for="i in list" :key=" i.id" @click="toArtist(i.id)">
          <img :src="i.img1v1Url" alt=""> {{i.name}}
      </li>
    </ul>
    <div class="no" v-if="list.length==0">
        很抱歉，未能找到相关的歌手
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
    };
  },
  methods:{
      toArtist(id){
          this.$router.push({name:'zhuanji',query:{id:id}})
      }
  },
  mounted() {
    this.$request({
      url: "/search",
      params: {
        keywords: this.$route.query.keywords,
        type: 100,
      },
    }).then((success) => {
      this.list = success.data.result.artists;
    });
  },
};
</script>

<style scoped>
.list {
  margin-top: 20px;
}
li {
  height: 70px;
  padding: 10px;
 
}

li:nth-child(2n) {
  background-color: #f6f6f7;
}
li:hover {
  background-color: #f3f3f3;
}
img{
    width: 50px;
    height: 50px;
    border-radius: 5px;
    vertical-align: middle;
}
.no{
  color: gray;
  line-height: 2.5em;
  text-align: center;
}
</style>